Skip to main content

Data Types

Conversions

The following is a matrix of supported by QQL data types for numerics and their conversions. The general conversion principle is that the higher priority always beats the lower priority: Int8 + Int16 = Int16.

tip

Note, that casting from higher to lower precision types causes data loss. For example cast from Int16 to Int8.

info
Timestamp(ms) (alias to Timestamp, has millisecond resolution) and Timestamp(ns) (nanosecond resolution) types are available since 5.6.67+.
Int8Int16Int32Int64Decimal64Float32Float64TimestampTimestamp(ns)
Int8Int32Int32Int32Int64Decimal64Float32Float64TimestampTimestamp(ns)
Int16Int32Int32Int32Int64Decimal64Float32Float64TimestampTimestamp(ns)
Int32Int32Int32Int32Int64Decimal64Float32Float64TimestampTimestamp(ns)
Int64Int64Int64Int64Int64Decimal64Float32Float64TimestampTimestamp(ns)
Decimal64Decimal64Decimal64Decimal64Decimal64Decimal64Float32Float64--
Float32Float32Float32Float32Float32Float32Float32Float64--
Float64Float64Float64Float64Float64Float64Float64Float64--
TimestampTimestampTimestampTimestampTimestamp---Int64Int64
Timestamp(ns)Timestamp(ns)Timestamp(ns)Timestamp(ns)Timestamp(ns)---Int64Int64

Operations with Timestamps

tip

0 = 1970-01-01 00:00:00.000 - Unix time in ms.

  • timestamp +- integer = timestamp
  • timestamp - timestamp = Int64
  • timestamp ><== (compare) timestamp = bool
  • timestamp(ns) +- integer = timestamp(ns)

In operations involving different resolutions (- or comparison operations), timestamps will be automatically converted to the most precise type timestamp(ns).

  • timestamp - timestamp(ns) = Int64
  • timestamp(ms) ><== (compare) timestamp(ns) = bool
SELECT '2022-10-10 10:10:10.010'd - '2022-10-10 10:10:10.000'd == 10
SELECT '2022-10-10 10:10:10.000'd + 10 == '2022-10-10 10:10:10.010'd
SELECT '2022-10-10 10:10:10.000'd + 1d5h == '2022-10-11 15:10:10.000'd

Operations with Arrays

When performing various operations with arrays of different types, the following principles apply:

  • Array(a) ◦ b = Array(type(a ◦ b))
  • a ◦ Array(b) = Array(type(a ◦ b))
  • Array(a) ◦ Array(b) = Array(type(a ◦ b))

where

  • a/b - data types
  • - any operation
Using operators with arrays
-- select all Entries array elements with Price fields and add 3 to each Price value
SELECT entries.price +3

Nullability Conversions

Any data field in QQL may be declared as nullable, regardless of its data type. If so declared, it may contain the special out-of-band value of NULL, which basically means "no data". Additionally, NULL values are generated by queries in special cases. A NULL value is formatted as an underscore character: "_", so it can be differentiated from an empty string. Unlike ORACLE, an empty string value is distinctly different from a NULL value.

Array elements can as well be nullable and not nullable.

When performing operations with two data types with different nullability, the following principle apply:

isNullable=true + isNullable=false = isNullable=true.

TrueFalse
TrueTrueTrue
FalseTrueFalse
info

Refer to Filtering to learn more about NaN and nullability.